package com.veetao.api.model;


/**
 * 
 * @author guohongtao
 * @date 2016年10月20日
 */
public class UserActionPermission {
	
	private static final int PERMISSION_TYPE_FORBID = 1;
	private static final int PERMISSION_TYPE_ALLOW = 2;
	private int id;
	private int userId;
	private int actionId;
	private int permissionType;
	private long startTime;
	private long endTime;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getActionId() {
		return actionId;
	}

	public void setActionId(int actionId) {
		this.actionId = actionId;
	}

	public int getPermissionType() {
		return permissionType;
	}

	public void setPermissionType(int permissionType) {
		this.permissionType = permissionType;
	}

	/**
	 * @return
	 * @author guohongtao
	 */
	public boolean isForbidPermission() {
		return this.permissionType == PERMISSION_TYPE_FORBID;
	}

	/**
	 * @return
	 * @author guohongtao
	 */
	public boolean isAllowPermission() {
		return this.permissionType == PERMISSION_TYPE_ALLOW;
	}
	
	
	public boolean isValid() {
		long now = System.currentTimeMillis();
		return now >= this.startTime && now <= this.endTime;
	}

	public long getStartTime() {
		return startTime;
	}

	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	public long getEndTime() {
		return endTime;
	}

	public void setEndTime(long endTime) {
		this.endTime = endTime;
	}

}
